import { IPSAppDEField } from './ipsapp-defield';
import { IPSAppDEMethodDTO } from './ipsapp-demethod-dto';
import { IPSAppDEMethodInput } from './ipsapp-demethod-input';
import { IPSAppDataEntity } from './ipsapp-data-entity';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppDEMethodInputImpl extends PSModelObjectImpl implements IPSAppDEMethodInput {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected keypsappdefield: IPSAppDEField | null = null;

  getKeyPSAppDEField(): IPSAppDEField | null {
    if (this.keypsappdefield != null) return this.keypsappdefield;
    const value = this.M.getKeyPSAppDEField;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.keypsappdefield = ipsappdataentity.findPSAppDEField(value);
    }
    return this.keypsappdefield;
  }

  get keyPSAppDEField(): IPSAppDEField | null {
    return this.getKeyPSAppDEField();
  }

  getKeyPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getKeyPSAppDEField();
    if (value == null) {
      throw new Error('未指定输入主键属性');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdemethoddto: IPSAppDEMethodDTO | null = null;

  getPSAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    if (this.psappdemethoddto != null) return this.psappdemethoddto;
    const value = this.M.getPSAppDEMethodDTO;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getParentPSModelObject('app.dataentity.IPSAppDataEntity') as IPSAppDataEntity;
    if (ipsappdataentity != null) {
      this.psappdemethoddto = ipsappdataentity.findPSAppDEMethodDTO(value);
    }
    return this.psappdemethoddto;
  }

  get psAppDEMethodDTO(): IPSAppDEMethodDTO | null {
    return this.getPSAppDEMethodDTO();
  }

  getPSAppDEMethodDTOMust(): IPSAppDEMethodDTO {
    const value = this.getPSAppDEMethodDTO();
    if (value == null) {
      throw new Error('未指定输入DTO对象');
    }
    return value;
  }

  get type(): 'NONE' | 'KEYFIELD' | 'KEYFIELDS' | 'DTO' | 'DTOS' | 'FILTER' | 'UNKNOWN' | 'USER' | 'USER2' {
    return this.M.type;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get output(): boolean {
    return this.M.output != null ? this.M.output : false;
  }

  get cls(): string {
    return 'PSAppDEMethodInputImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'app.dataentity.IPSAppDEMethodInput' || cls == 'dataentity.service.IPSDEMethodInput') return true;
    return super.instanceof(cls);
  }
}
